/*
 * @Description: 
 * @Version: 2.0
 * @Autor: ftt
 * @Date: 2022-06-10 14:32:06
 * @LastEditors: TT
 * @LastEditTime: 2022-06-24 18:04:45
 */

import 'package:sp_util/sp_util.dart';

import '../config/config_index.dart';

class CommonSpUtil {
  /// 获取token
  static String? getUserToken() {
    return SpUtil.getString(
      NormalFlagIdConfig.usertoken,
    );
  }

  /// 存token
  static saveUserToken({required String token}) {
    return SpUtil.putString(
      NormalFlagIdConfig.usertoken,
      token,
    );
  }

  /// 存用户信息
  static saveUserInfo({required Map info}) {
    return SpUtil.putObject(NormalFlagIdConfig.userinfo, info);
  }

  /// 取用户信息
  static Map? getUserInfo() {
    return SpUtil.getObject(NormalFlagIdConfig.userinfo);
  }

  /// 更新app 安装状态
  static savefirstinstal({required int instal}) {
    return SpUtil.putInt(
      NormalFlagIdConfig.firstinstal,
      instal,
    );
  }

  /// 获取 app 次数
  static int getfirstinstal() {
    return SpUtil.getInt(NormalFlagIdConfig.firstinstal) ?? 0;
  }

  /// 深色模式 0: 关闭 1: 开启 2: 随系统
  static int getThemeType() {
    return SpUtil.getInt(NormalFlagIdConfig.themeType) ?? 0;
  }

  /// 存深色模式
  static saveThemeType({required int type}) {
    return SpUtil.putInt(NormalFlagIdConfig.themeType, type);
  }

  /// 存语言配置
  static saveLauchType({required String launch}) {
    return SpUtil.putString(NormalFlagIdConfig.launchType, launch);
  }

  /// 获取语言配置
  static String getLaunchType() {
    return SpUtil.getString(NormalFlagIdConfig.launchType) ?? "zh_CN";
  }
}
